import { defineStore } from "pinia"

export let useCach = defineStore('cach', {
    state: () => {
        return {
            collapse: false, //侧边栏折叠
            // 编辑类型
            //模态框类型
            modalStatus: "", //this.$store.this.stateoptions;
            //模态框是否显示
            showModal: false,
            ifloading: false, //访问后台状态
            ifsave: true, //是否保存状态
            UserMsg: {}, //用户信息
            //站内未读消息条数
            unredmsgNum: 0,
            ifappPack: false, //是否app打包
            ifwebsocketconnect: false, //是否webscoket连接
            /* 试验任务计划页面 */
            looktasktype: 1, //1查看任务单  2查看任务计划详情
            /* 选择弹窗 */
            selectedList: null,
            /* 列表页保留信息 */
            listPageData: null,
            /* 登录权限信息 */
            login_permission: [],
            //用户信息页面，msg用户资料，psd修改密码
            userInfoIndex: 'msg',
            // 是否来自于PDM
            show_PDM: false,
            //是否隐藏功能栏
            ifHidetab: false,
            /* 大屏展示 */
            /* 科室角色 存储当前科室 */
            departmentRoles: null,
            /* mqtt */
            ifmqttcon: false, //mqtt是否连接
            mqtt_Data: "", //mqtt接受到的数据
            /* mqtt */
            globHeight: '',
            //选择人员及其他的内容
            chooseRow: null,
            //是否清空
            isCleanChooseRow: false,
            //初始化弹框数据
            initChooseRow: null,
            tableInfo: null
        }
    },
    actions: {
        //模态框状态更新，是否弹出，true是，false否
        changeShowModal(showModal) {
            this.showModal = showModal
        },

        ifwebsocketconnect(ifwebsocketconnect) {
            this.ifwebsocketconnect = ifwebsocketconnect
        },

        //更新模态框类型
        changeModalStatus(modalStatus) {
            this.modalStatus = modalStatus
        },

        selectedList(selectedList) {
            this.selectedList = selectedList
        },

        changeSave(ifsave) {
            this.ifsave = ifsave
        },

        setUserMsg(UserMsg) {
            this.UserMsg = UserMsg
        },

        unredmsgNum(unredmsgNum) {
            this.unredmsgNum = unredmsgNum
        },


        collapse(collapse) {
            this.collapse = collapse
        },

        looktasktype(looktasktype) {
            this.looktasktype = looktasktype
        },

        currentRow(currentRow) {
            this.currentRow = currentRow
        },

        listPageData(listPageData) {
            this.listPageData = listPageData
        },

        login_permission(login_permission) {
            this.login_permission = login_permission
        },

        changePDM(type) {
            this.show_PDM = type
        },

        //打印信息
        printContent(content) {
            this.printContent = content
        },

        //是否隐藏tab栏
        ifHidetab(ifHidetab) {
            this.ifHidetab = ifHidetab
        },

        //科室角色 存储当前科室
        update_departmentRoles(departmentRoles) {
            this.departmentRoles = departmentRoles
        },

        /* mqtt */
        ifmqttcon(ifmqttcon) {
            this.ifmqttcon = ifmqttcon
        },

        mqtt_Data(mqtt_Data) {
            this.mqtt_Data = mqtt_Data
        },

        //修改弹框高度
        chengeGlobHeight(height) {
            this.globHeight = height
        },

        //修改选择人员及其他的内容
        changeChooseRow(row, isDelete = false){
            this.chooseRow = JSON.parse(JSON.stringify(row))
            this.isCleanChooseRow = isDelete
        },

        //修改弹框初始化数据
        changeInitChooseRow(initData){
            this.initChooseRow = initData
        },

        //修改当前table列表暂存信息
        changeTableInfo(info) {
            this.tableInfo = JSON.parse(JSON.stringify(info))
        },
    }
})